package com.A1908.dao.impl;

import com.A1908.dao.UserFeastTypeDao;
import com.A1908.entity.UserFeastType;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class UserFeastTypeDaoImpl extends BaseDao implements UserFeastTypeDao {
    Connection connection = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    @Override
    public List<UserFeastType> getAllFeastType() {
        connection = conn();
        String sql = "select * from userfeasttype;";
        Object[] objects = {};
        pstmt = pstmt(connection,sql,objects);
        List<UserFeastType> list = new ArrayList<UserFeastType>();
        try {
            rs = pstmt.executeQuery();
            while (rs.next()){
                UserFeastType userFeastType = new UserFeastType();
                userFeastType.setId(rs.getInt("id"));
                userFeastType.setTypeName(rs.getString("typeName"));
                userFeastType.setCreatDate(rs.getString("creatDate"));
                userFeastType.setIsDelete(rs.getInt("isDelete"));

                list.add(userFeastType);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            cloesAll(connection,pstmt,rs);
        }

        return list;
    }

    @Override
    public int addFeastType(UserFeastType userFeastType) {
        return 0;
    }

    @Override
    public int updateFeastType(UserFeastType userFeastType) {
        return 0;
    }

    @Override
    public int delFeastType(int id) {
        return 0;
    }
}
